package com.ytf.test.ninth.abs;

import com.ytf.test.ninth.Note;

abstract class Instrument{
    public abstract void play(Note note);
    public String what(){
        return "Instrument";
    }
    public abstract void adjust();
}
class Wind extends Instrument{

    @Override
    public void play(Note note) {
        System.out.println("Wind.play() "+note);
    }
    @Override
    public String what() {
        return "Wind";
    }
    @Override
    public void adjust() {

    }
}
class Percussion extends Instrument{

    @Override
    public void play(Note note) {
        System.out.println("Percussion.play() "+note);
    }
    @Override
    public String what() {
        return "Percussion";
    }
    @Override
    public void adjust() {

    }
}
class Stringed extends Instrument{

    @Override
    public void play(Note note) {
        System.out.println("Stringed.play() "+note);
    }
    @Override
    public String what() {
        return "Stringed";
    }
    @Override
    public void adjust() {

    }
}
class Brass extends Instrument{

    @Override
    public void play(Note note) {
        System.out.println("Brass.play() "+note);
    }
    @Override
    public String what() {
        return "Brass";
    }
    @Override
    public void adjust() {

    }
}
/**
 * @author: YTF
 * @date: 2025/1/25 15:07
 * @version: 1.0
 * @description:
 */
public class Music4 {

    private static void tune(Instrument instrument) {
        instrument.play(Note.MIDDLE_C);
    }
    private static void tuneAll(Instrument[] instrument) {
        for (int i = 0; i < instrument.length; i++) {
            tune(instrument[i]);
        }
    }

    public static void main(String[] args) {
        Instrument[] instruments = {new Wind(),new Percussion(),new Stringed(),new Brass()};
        tuneAll(instruments);
        /**
         * OutPut:
         * Wind.play() MIDDLE_C
         * Percussion.play() MIDDLE_C
         * Stringed.play() MIDDLE_C
         * Brass.play() MIDDLE_C
         *
         */
    }
}
